package com.baidu.config;

import java.io.BufferedInputStream;
import java.util.Properties;

@SuppressWarnings("serial")
public class CtxConfig extends Properties {
	private static CtxConfig self = null;

	public synchronized static CtxConfig getInstance() throws Exception {
		if (self == null) {
			self = new CtxConfig();
		}

		return self;
	}

	private CtxConfig() throws Exception {
		super();
		this.clear();
		String cfgFilePath = "/conf/context_register.properties";
		BufferedInputStream is = null;
		try {
			is = new BufferedInputStream(CtxConfig.class.getResourceAsStream(cfgFilePath));
			this.load(is);
		} catch (Exception e) {
			throw e;
		} finally {
			if (is != null) {
				is.close();
			}
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		CtxConfig cfg = CtxConfig.getInstance();

		System.out.println(cfg.getProperty("test_ctx"));
	}

}
